Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial range request support #1388

Merged
merged 6 commits into from
Jan 7, 2021
Merged

Conversation

butonic
Copy link
Contributor

@butonic butonic commented Jan 6, 2021

The desktop client uses range requests to continue downloads. It does not expect the full content / a 200 OK response and would assemble a broken file.

  • There is a lot of code duplication right now, but I want to see the testsuite effects first
  • refactor GET into a function that is used by tus and simple datatx implementations, or ... just handle GET in a different handler?
  • move datatx/range.go to a util.go? or into a handler dir with get.go?
  • changelog
  • update expected tests failures
  • implement multiple range header

EOS has to download the whole file to the storage provider ... I did not find an option to xrdcopy that would allow reducing the size. So I left the FS.Download() interface as is. It actually is just an Open() and should be renamed anyway.

deprecates #701

Signed-off-by: Jörn Friedrich Dreyer jfd@butonic.de

@butonic butonic requested a review from labkode as a code owner January 6, 2021 14:30
@update-docs
Copy link

update-docs bot commented Jan 6, 2021

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@butonic butonic force-pushed the range-header branch 2 times, most recently from 9b4676f to a381108 Compare January 6, 2021 22:24
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@butonic
Copy link
Contributor Author

butonic commented Jan 6, 2021

all green, good to merge!

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
/*
if md.Checksum != "" {
w.Header().Set("OC-Checksum", md.Checksum)
}
*/
if _, err := io.Copy(w, httpRes.Body); err != nil {
var c int64
if c, err = io.Copy(w, httpRes.Body); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return an error status in this case, right? Currently it would just return OK or partial content if the GET request above didn't return any error. Same for the errors below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we can't because the header has already been sent and the Copy is streaming the bytes.

All we can do is log that something went wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if the copy fails, user would still receive a 200 with corrupt file contents.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. even if we would buffer everything into ram ... we cannot change the http header when the body is being sent. The best we can do is log an error.

internal/http/services/owncloud/ocdav/get.go Show resolved Hide resolved
pkg/rhttp/datatx/download/download.go Outdated Show resolved Hide resolved
pkg/rhttp/datatx/download/download.go Outdated Show resolved Hide resolved
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@butonic butonic requested a review from ishank011 January 7, 2021 10:55
ishank011
ishank011 previously approved these changes Jan 7, 2021
@ishank011
Copy link
Contributor

Lint needs to be fixed

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants